home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4121 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.3 KB

  1. Path: ni1.ni.net!usenet
  2. From: Tom Benoist <ben@ifx.com>
  3. Newsgroups: comp.sys.sgi.hardware,comp.lang.c++
  4. Subject: Re: Help with serial/tty2 communication (write ok, read NOT).
  5. Date: 28 Jan 1996 06:45:45 GMT
  6. Organization: Interactive Effects
  7. Message-ID: <4ef62p$8t2@ni1.ni.net>
  8. References: <4ebkuaINNdqp@retriever.cs.umbc.edu>
  9. NNTP-Posting-Host: mike.ifx.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.12 (X11; I; IRIX 5.2 IP22)
  14. X-URL: news:4ebkuaINNdqp@retriever.cs.umbc.edu
  15.  
  16. Its pretty difficult to see what your doing wrong since,
  17. 1. you didnt show your ioctl setup.
  18. 2. You didnt mention if you understood the implications of O_NONBLOCK
  19.    (ie...your reads return FALSE until a byte is available)
  20.  
  21. In any case, the following works for most applications.....
  22.  
  23. -Tom
  24.  
  25.  
  26.  
  27.     int port;
  28.     struct termio t;
  29.  
  30.  
  31.     port = open("/dev/ttyd2", O_RDWR | O_NDELAY, 0666);
  32.     t.c_iflag = IGNBRK;
  33.     t.c_oflag = 0;
  34.  
  35.     t.c_cflag = B38400 | CS8 | CREAD | CLOCAL;
  36.     t.c_lflag = 0;
  37.  
  38.     t.c_cc[VMIN] = 1;
  39.     t.c_cc[VTIME] = 1;
  40.  
  41.     t.c_iflag &=~(IXON | IXOFF | IXANY);
  42.  
  43.     ioctl(port, TCSETAW, &t);
  44.  
  45.  
  46. -- 
  47. _____________________________________________________________________
  48. Tom Benoist                                        Email: ben@ifx.com 
  49. Interactive Effects                      Amazon http://www.ifx.com/ie
  50.  
  51.